package com.me.libgdx_test;

import java.util.ArrayList;

class ClassScoreHolder{
	private float total_score = 0;
	float ending_damage_done = 0;
	float ending_damage_taken = 0;
	float ending_gold = 0;
	float board_uncovered = 0;
	float win_bonus = 0;
	float ending_rank = 0;
	int ending_kills = 0;
	int ending_deaths = 0;
	int ending_bonus;
	private ArrayList<String> score_strings;
	private boolean medal_held;
	
	ClassScoreHolder(ClassBoardHolder board, int damage_done, int damage_taken, int ending_gold, int ending_kills, int ending_deaths,
			int ending_level, int ending_bonus, boolean medal_held){
		
		score_strings = new ArrayList<String>();
		
		ClassPlaceObjects ending_board = board.get_board_parameters();
		
		ending_damage_done = damage_done;
		ending_damage_taken = damage_taken;
		board_uncovered = (int)((ending_board.get_dungeon_dimensions().x * ending_board.get_dungeon_dimensions().y)  - ending_board.get_shroud().size());
		if(board.get_bosses()<1){
			win_bonus = 1;
		}
		ending_rank = ending_level;

		if(win_bonus == 1){
			this.ending_gold = ending_gold;
		}
		this.ending_kills = ending_kills;
		this.ending_deaths = ending_deaths;
		this.ending_bonus = ending_bonus;
		this.medal_held = medal_held;
		
		calculate_score();
	}
	public boolean medal_held(){
		return medal_held;
	}
	public boolean dungeon_completed(){
		return win_bonus>0;
	}
	public String get_score_text(){
		String compiled_text = "";
		for(String text:score_strings){
			compiled_text+=text+"\n";
		}
		return compiled_text;
	}
	public float get_final_score(){
		return total_score;
	}
	private void calculate_score(){
		total_score += ending_damage_done * 3;
		score_strings.add(ScoreFormatter("Damage Done",(int)ending_damage_done,3));
		total_score += ending_damage_taken * 3;
		score_strings.add(ScoreFormatter("Damage Taken",(int)ending_damage_taken,3));
		total_score += board_uncovered * 4;
		score_strings.add(ScoreFormatter("Board Uncovered",(int)board_uncovered,4));
		total_score += win_bonus * 5000;
		score_strings.add(ScoreFormatter("Win Bonus",(int)win_bonus,5000));
		total_score += ending_rank * 300;
		score_strings.add(ScoreFormatter("Ending Level",(int)ending_rank,300));
		total_score *= ending_bonus;
		score_strings.add(ScoreFormatter("Ending Bonus",(int)total_score,ending_bonus));
		score_strings.add("Total Score = " + total_score);
	}
	private String ScoreFormatter(String value_name, int value_origin, int value_multiplier){
		String score_row = "";
		score_row += value_name+":";
		score_row += " " + value_origin;
		score_row += " x " + value_multiplier;
		score_row += " = " + (value_origin*value_multiplier);
		return score_row;
	}
}
